package bytes;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @Description
 * @Author zhaobaolin
 * @Date 2018/11/11
 */
public class BufferedOutputStreamExample {
    public static void main(String[] args) {
        demo();
    }

    private static void demo()
    {
        try(FileOutputStream f = new FileOutputStream("./io/src/bytes/bufOutput.txt")){
            String source = "1234567890";
            BufferedOutputStream buf = new BufferedOutputStream(f);
            byte[] b = source.getBytes();

            for(int i=0;i<b.length;i++){
                if(i == 3){
                    buf.flush();
                    buf.write('-');
                }
                if(i == 6){
                    buf.flush();
                    buf.write('-');
                }
                buf.write(b[i]);
            }
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
